<template>
  <div class="text-form-wrapper">
    <el-form :model="textSubjectForm" label-width="80px">
      <el-form-item label="文本内容">
        <el-input v-model="textSubjectForm.text" placeholder="请输入文本" />
      </el-form-item>
    </el-form>
    <el-form :model="textStyleForm" label-width="80px">
      <el-form-item label="文本大小">
        <el-input v-model="textStyleForm.fontSize" placeholder="请输入文本大小" />
      </el-form-item>
      <el-form-item label="文本粗细">
        <el-select v-model="textStyleForm.fontWeight" placeholder="请选择文本粗细">
          <el-option
            v-for="item in fontWeightOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="行高">
        <el-input v-model="textStyleForm.lineHeight" placeholder="请输入行高" />
      </el-form-item>
      <el-form-item label="对齐方式">
        <el-select v-model="textStyleForm.textAlign" placeholder="请选择文本对齐方式">
          <el-option
            v-for="item in textAlignOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="文本颜色">
        <el-color-picker v-model="textStyleForm.color" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive } from "vue";
import { textAlignOptions, fontWeightOptions } from "@/config/form";
export default defineComponent({
  name: "TextForm",
  props: {
    property: {
      type: Object,
      default: () => ({
        textAlign: "left",
        fontSize: "16",
        color: "",
        fontWeight: "",
        lineHeight: "",
        backgroundImage: "",
        backgroundColor: "",
      }),
    },
    subject: {
      type: Object,
      default: () => ({
        text: "text",
      }),
    },
  },
  setup(props) {
    const textStyleForm = reactive(props.property);
    const textSubjectForm = reactive(props.subject);
    return {
      textStyleForm,
      textSubjectForm,
      textAlignOptions,
      fontWeightOptions,
    };
  },
});
</script>

<style lang="scss" scoped></style>
